package client.mobile;

import client.utility.Id;
import client.utility.Point2d;

public class Mobile {

	private String name;
	private Point2d position;
	private Id id;
	private int health;
	private int maxHealth;
	
	public static Mobile constructFromString(String s){
		String[] split=s.split(";");
		Mobile res=new Mobile();
		
		try{
			res.name=split[0];
			res.position=Point2d.fromString(split[1]);
			res.id=new Id(Integer.parseInt(split[2]));
			res.health = Integer.parseInt(split[3]);
			res.maxHealth = Integer.parseInt(split[4]);
			return res;
		}catch(Exception ex){return null;}
	}
	
	public Mobile(){}
	
	public Mobile(String name, Point2d pos, Id id){
		this.name=name;
		this.position=pos;
		this.id=id;
	}

	public Id getId() {
		return id;
	}

	public void setPosition(Point2d p) {
		position=p;
		
		//System.out.println(p);
	}
	
	public Point2d getPosition(){
		return position;
	}

	public String getName() {
		return name;
	}
	
	public int getHealth(){
		return health;
	}
	
	public void setHealth(final int health){
		this.health = health;
	}
	
	public void modifyHealth(final int delta){
		this.health += delta;
	}

	public int getMaxHealth() {
		// TODO Auto-generated method stub
		return maxHealth;
	}

	public void setMaxHealth(int maxHealth2) {
		this.maxHealth = maxHealth2;
		
	}
}